<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习2</title>
</head>
<body>
    <input type="text" id="aa">
    <input type="text" id="bb">
    <input type="button" id="submit" value="提交">
    <Script src="js/jquery.min.js"></Script>
    <Script>
        //设置button的onclick事件
        let button = document.querySelector("#submit");
        let aaInput = document.querySelector("#aa");
        let bbInput = document.querySelector("#bb");

        button.onclick = function(){
            $.ajax({
                type: "post",
                url: "testPost2",
                //设置body格式
                contentType: "application/json",
                //获取JSON的内容
                data: JSON.stringify({
                    aa: aaInput.value,
                    bb: bbInput.value
                }),
                success: function(body){
                    console.log(body);
                }
            })
        }
    </Script>
</body>
</html>